import request from "../utils/request";

export function getCourseList(pageIndex = 1, pageSize = 10) {
  return request({
    url: "/api/course/page",
    method: "get",
    params: {
      pageIndex: pageIndex,
      pageSize: pageSize
    }
  });
}

export function courseProgressUpdate(courseId, progress) {
  return request({
    url: "/api/course/progress/update",
    method: "post",
    data: {
      courseVideoId: courseId,
      progress: progress
    }
  });
}

export function playCourse(courseVideoId) {
  return request({
    url: '/api/course/play', method: 'post', data: {
      "courseVideoId": courseVideoId,
    }
  });
}
export function findCoursePlayHistory(courseVideoId, pageIndex, pageSize) {
  return request({
    url: '/api/course/' + courseVideoId + '/history', method: 'get', params: { "pageIndex": pageIndex, "pageSize": pageSize }
  });
}
export function getLiveCourseList(pageIndex = 1, pageSize = 10) {
  return request({
    url: "/api/live-course/page",
    method: "get",
    params: {
      pageIndex: pageIndex,
      pageSize: pageSize
    }
  });
}

export function liveCourseSign(courseId) {
  return request({
    url: "/api/live-course/sign-in",
    method: "post",
    data: {
      liveCourseId: courseId
    }
  });
}

export function liveCourseState(courseId) {
  return request({
    url: "/api/live-course/state",
    method: "post",
    data: {
      liveCourseId: courseId
    }
  });
}

export function courseMesssageList(courseId, lastMsgId = 0) {
  return request({
    url: "/api/message/list",
    method: "get",
    params: {
      liveCourseId: courseId,
      lastMsgId: lastMsgId
    }
  });
}

export function courseMesssageNonList(token, userId, courseId, apiTime, lastMsgId = 0) {
  return request({
    url: "/api/message/non/list",
    method: "get",
    params: {
      liveCourseId: courseId,
      userId: userId,
      token: token,
      apiTime: apiTime,
      lastMsgId: lastMsgId
    }
  });
}
